<?php

class users extends Controller
{
	public function index ()
	{
		
		$model = new user();
	
		$identity = $model->logIn($_POST['username'],$_POST['password']);
		if (isset($identity[0]))
		{
			session_start();
			$_SESSION['stud_no'] = $identity[0]['stud_no'];
			$_SESSION['first_name'] = $identity[0]['firstname'];
			$_SESSION['last_name'] = $identity[0]['lastname'];
			$_SESSION['middle_name'] = $identity[0]['middlename'];
			var_dump($identity[0]['admin'] );
			if ($identity[0]['admin'] == 1)	
			{
				$_SESSION['admin'] = $identity[0]['admin'];
				header("Location: /admin/home");
			}
			else header("Location: /member/membersIndex");

		}
		else
		{
			$_SESSION['wrong'] = true;
			header("Location: /login");
		}
		
		
	
	}
}
